package com.bj58.analysis.tools.etl.bean;

import java.util.List;

import org.apache.commons.lang.StringUtils;


import com.bj58.analysis.tools.common.bean.ActionData;
import com.bj58.analysis.tools.common.bean.LogBean;

public class ETLActionBean implements LogBean {
	private String cookieID = ""; // cookieId
	private String epoch = ""; // 时间戳
	private String userIp = ""; // 客户端用户ip
	private String loginUid = ""; // 当前登陆用户id
	private String busine = ""; // 业务线
	private String catePath = ""; // cateid的fullpaths
	private String areaPath = ""; // areaid的fullpaths
	private String pageType = ""; // 当前页面业务类型(list|detail|post等)
	private String page = ""; // 二级业务线类型
	private String url = ""; // 当前url
	private String referrer = ""; // 来路访问url
	private String actionDataStr; // 行为数据属性对象集合
	private String trackUrl = "";// 公共参数集合，在commonparams上
	private String userAgent = ""; // userAgent串
	private String source = ""; //渠道
	private String version = ""; // 日志版本，不提供提取方法
	
	/** 附加字段 **/
	private String refDomain = "";// 来路域名
	private String clickId = "";// 当前点击事件的ClickID,在commonparams上
	private String GTID = "";// 当前页面的一次访问的唯一标识符GTID，在trackurl上
	private String pGTID = "";// 当前页面的pGTID，在当前url上
	private String pClickId = "";// ClickId，在当前url上，属于上一个页面的
	
	private List<ActionData> actionDataList = null;// 行为数据属性对象集合
	public String getCookieID() {
		return cookieID;
	}
	public void setCookieID(String cookieID) {
		this.cookieID = cookieID;
	}
	public String getEpoch() {
		return epoch;
	}
	public void setEpoch(String epoch) {
		this.epoch = epoch;
	}
	public String getUserIp() {
		return userIp;
	}
	public void setUserIp(String userIp) {
		this.userIp = userIp;
	}
	public String getLoginUid() {
		return loginUid;
	}
	public void setLoginUid(String loginUid) {
		this.loginUid = loginUid;
	}
	public String getBusine() {
		return busine;
	}
	public void setBusine(String busine) {
		this.busine = busine;
	}
	public String getCatePath() {
		return catePath;
	}
	public void setCatePath(String catePath) {
		this.catePath = catePath;
	}
	public String getAreaPath() {
		return areaPath;
	}
	public void setAreaPath(String areaPath) {
		this.areaPath = areaPath;
	}
	public String getPageType() {
		return pageType;
	}
	public void setPageType(String pageType) {
		this.pageType = pageType;
	}
	public String getPage() {
		return page;
	}
	public void setPage(String page) {
		this.page = page;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getReferrer() {
		return referrer;
	}
	public void setReferrer(String referrer) {
		this.referrer = referrer;
	}
	public String getUserAgent() {
		return userAgent;
	}
	public void setUserAgent(String userAgent) {
		this.userAgent = userAgent;
	}
	public String getVersion() {
		return version;
	}
	public void setVersion(String version) {
		this.version = version;
	}
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
	public String getRefDomain() {
		return refDomain;
	}
	public void setRefDomain(String refDomain) {
		this.refDomain = refDomain;
	}
	public String getClickId() {
		return clickId;
	}
	public void setClickId(String clickId) {
		this.clickId = clickId;
	}
	public String getGTID() {
		return GTID;
	}
	public void setGTID(String gTID) {
		GTID = gTID;
	}
	public String getpGTID() {
		return pGTID;
	}
	public void setpGTID(String pGTID) {
		this.pGTID = pGTID;
	}
	public String getpClickId() {
		return pClickId;
	}
	public void setpClickId(String pClickId) {
		this.pClickId = pClickId;
	}
	public String getActionDataStr() {
		return actionDataStr;
	}
	public void setActionDataStr(String actionDataStr) {
		this.actionDataStr = actionDataStr;
	}
	public String getTrackUrl() {
		return trackUrl;
	}
	public void setTrackUrl(String trackUrl) {
		this.trackUrl = trackUrl;
	}
	public List<ActionData> getActionDataList() {
		return actionDataList;
	}
	public void setActionDataList(List<ActionData> actionDataList) {
		this.actionDataList = actionDataList;
	}
	/**
	 * @description 通过输入级别获取分类的级别
	 * @param level
	 *            级数，比如1级、2级、3级
	 * @return 返回对应的级别
	 */
	public String getCatePathOfLevel(int level) {
		String tu = getCatePath();
		return parserClassType(tu, level-1);
	}

	/**
	 * @description 通过输入级数获取地域分类级别
	 * @param level
	 *            级数，比如1级、2级、3级
	 * @return 返回对应的级别
	 */
	public String getAreaPathOfLevel(int level) {
		String ta = getAreaPath();
		return parserClassType(ta, level-1);
	}

	// 解析级别类型
	private String parserClassType(String src, int index) {
		String result = null;
		if (index < 0)
			return result;

		if (StringUtils.isNotBlank(src)) {
			String[] srcS = src.split(",", -1);
			if (srcS.length > index) {
				result = srcS[index];
			}
		}
		return result;
	}

	@Override
	public String toString() {
		return cookieID + "\001" + epoch + "\001" + userIp + "\001" + loginUid
				+ "\001" + busine + "\001" + catePath + "\001" + areaPath
				+ "\001" + pageType + "\001" + page + "\001" + url + "\001"
				+ referrer + "\001" + userAgent + "\001"
				+ version + "\001" + refDomain + "\001" + clickId + "\001"
				+ GTID + "\001" + pGTID + "\001" + pClickId
				+ "\001" + trackUrl + "\001" + actionDataList;
	}

	
	
}
